<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ include file="/page/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%@ include file="/adapter/adapter-bootstrap.jsp" %>
<script type="text/javascript">
function save(){

	//校验必输项，如果必须项为空，则不进行保存，提示修改。
	if($('#forwardChannelId').val() == ''){
		alert('渠道标识不能为空!');
		return;
	}

	if($('#forwardChannelName').val() == ''){
		alert('渠道名称不能为空!');
		return;
	}
	
	var str_data=$("#channelinfo input").map(function(){
		   return ($(this).attr("name")+'='+$(this).val());
		 }).get().join("&") ;
	//alert("str_data"+str_data);
    $.ajax({
        url:"${ctx}/appChannelForward/saveAppChannelForward",
        type: "POST",      
        dataType:"json",
        data: str_data,
        async: false,
        success: function(data) {
        	if(data.flag>0){
	            alert("保存成功！");	
        	} else {
				alert("保存失败,没有修改到记录!");
        	}
        },
        error: function() {
          alert("error");
        }
      });
}
function  goBack(){
	window.history.back(-1);
}
function  changeValue1(http_Stream_Type){
	   document.getElementById("http_Stream_Type").value=http_Stream_Type;	
}
function  changeValue2(channel_Format_Type){
	   document.getElementById("channel_Format_Type").value=channel_Format_Type;	
}
function  changeValue3(forward_Channel_Type){
	   document.getElementById("forward_Channel_Type").value=forward_Channel_Type;	
}
</script>
</head>
<body>
<div class="panel panel-default">
	<div class="panel-heading">
		<h3 class="panel-title">
                   创建交易转发渠道
		</h3>
	</div>
	<div class="panel-body">
		<form class="form-horizontal" role="form" id="channelinfo">
			<legend>渠道基本信息</legend>
			<div class="form-group">
				<label class="col-xs-2 control-label" for="appId">应用标识</label>
				<div class="col-xs-4">
					<input class="form-control" id="appId" name="appId" type="text" readonly="readonly" value="${appid}"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-2 control-label" for="forwardChannelId">渠道标识<font color="red">*</font></label>
				<div class="col-xs-4">
					<input class="form-control" id="forwardChannelId" name="forwardChannelId" type="text" value="" placeholder="渠道的唯一标识"/>
				</div>
				<label class="col-xs-2 control-label" for="forwardChannelName">渠道名称<font color="red">*</font></label>
				<div class="col-xs-4">
					<input class="form-control" id="forwardChannelName" name="forwardChannelName" type="text" value="" placeholder="命名渠道"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-2 control-label" for="forwardChannelType">渠道类型<font color="red">*</font></label>
				<div class="col-xs-4">
					<input class="form-control" id="forward_Channel_Type" name="forwardChannelType" type="hidden" value=""/>
					<select class="form-control" id="forwardChannelType" name="forwardChannelType" onclick="changeValue3(this.value)" >
						<option value="HTTP">HTTP渠道</option>
						<option value="TCP">TCP/IP渠道</option>
					</select>
				</div>
				<label class="col-xs-2 control-label" for="httpStreamType">HTTP交互类型</label>
				<div class="col-xs-4">
					<input class="form-control" id="http_Stream_Type" name="httpStreamType" type="hidden" value=""/>
					<select class="form-control" id="httpStreamType" name="httpStreamType" onclick="changeValue1(this.value)">
						<option value="01">数据流</option>
						<option value="02">POST</option>
						<option value="03">GET</option>
						<option value="04">文本流</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-2 control-label" for="forwardChannelUrl">渠道通讯地址<font color="red">*</font></label>
				<div class="col-xs-4">
					<input class="form-control" id="forwardChannelUrl" name="forwardChannelUrl" type="text" value="" placeholder="TCP配置为：IP:PORT,HTTP时直接配置为http地址"/>
				</div>
				<label class="col-xs-2 control-label" for="channelCharset">渠道报文字符编码<font color="red">*</font></label>
				<div class="col-xs-4">
					<input class="form-control" id="channelCharset" name="channelCharset" type="text" value="" placeholder="UTF-8或GBK或其它"/>
				</div>
			</div>
			<legend>组/解包处理</legend>
			<div class="form-group">
				<label class="col-xs-2 control-label" for="channelFormatType">渠道报文格式<font color="red">*</font></label>
				<div class="col-xs-4">
					<input class="form-control" id="channel_Format_Type" name="channelFormatType" type="hidden" value=""/>
					<select class="form-control" id="channelFormatType" name="channelFormatType" onclick="changeValue2(this.value)" >
						<option value="01">JSON</option>
						<option value="02">XML</option>
						<option value="03">KEYVALUE</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-2 control-label" for="channelHeadDefine">渠道报文头定义</label>
				<input class="form-control" id="channelHeadDefine" name="channelHeadDefine" type="hidden" value=""/>
				<div class="col-xs-4">
					<input class="form-control" id="channelHeadDefine" name="channelHeadDefine" type="text" value="${appChannelForward.channelHeadDefine}" placeholder="可配置一段固定的报文头内容在此,主要用于HTTP方式,TCP方式尚未使用"/>
				</div>
				<label class="col-xs-2 control-label" for="channelHeadDefine">渠道约定交易码字段</label>
				<div class="col-xs-4">
					<input class="form-control" id="channelTradeCodeField" name="channelTradeCodeField" type="text" value="${appChannelForward.channelHeadDefine}" placeholder="有约定则在此配置"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-2 control-label" for="PackProcessorClass">渠道组/解包处理类<font color="red">*</font></label>
				<div class="col-xs-4">
					<input class="form-control" id="PackProcessorClass" name="PackProcessorClass" type="text" value="" placeholder="处理类填写为Spring中的beanId"/>
				</div>
			</div>
			<div class="form-group text-center">
				<button type="button" class="btn btn-default" onclick="save();">保存</button>
				<button type="button" class="btn btn-default" onclick="goBack()">返回</button>
			</div>
		</form>
	</div>
</div>
</body>
</html>